home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / rcs55.zip / UNLINK.C < prev   
C/C++ Source or Header  |  1991-09-15  |  668b  |  40 lines

  1. /* DOS version of UNIX compatible unlink()
  2.  *
  3.  * Unlinks a file even if its attributes say READ-ONLY.
  4.  *
  5.  * NOTE: SMALL MEMORY MODEL ONLY
  6.  */
  7.  
  8. #pragma inline
  9.  
  10. #include <dos.h>
  11.  
  12. static char RCSid[] = "$Id: unlink.c%v 1.2 1991/08/23 14:46:21 SGP Exp $";
  13.  
  14. int unlink (const char *fname)
  15. {
  16.     /* Set file attributes to allow READ AND WRITE access */
  17.  
  18.     asm    {
  19.         mov        cx,0;                // Read & Write
  20.         mov        dx,fname;
  21.         mov        ax,4301h;            // DOS Set File Attribute
  22.         int        21h;
  23.     };
  24.  
  25.     /* Delete the file */
  26.  
  27.     asm {
  28.         mov        dx,fname;
  29.         mov        ah,41h;                // Delete file
  30.         int        21h;
  31.         jc        delete_failed;
  32.     };
  33.  
  34.     return (0);
  35.  
  36. delete_failed:
  37.  
  38.     return (_AX);
  39. }
  40.